package com.xiaotu.mybatis.service;

import com.xiaotu.mybatis.mapper.AMapper;
import com.xiaotu.mybatis.model.AModel;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

/**
 * @author Mr.zhang
 * @create 2021-11-17 20:24
 */
@Service
@AllArgsConstructor
public class AService {

    private final AMapper aMapper;

    public AModel getA() {
        return aMapper.selectA();
    }

    public void insert(AModel aModel) {
        Example example = new Example(AModel.class);
        example.createCriteria().andEqualTo("aDate",aModel.getADate());
        AModel aModel1 = aMapper.selectOneByExample(example);
        if (null == aModel1){
            aMapper.insert(aModel);
        }
    }
}
